<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Redis vs Memcached：深度对比分析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .feature-icon {
            transition: all 0.3s ease;
        }
        
        .feature-icon:hover {
            transform: scale(1.1) rotate(5deg);
        }
        
        .section-title {
            position: relative;
            display: inline-block;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #667eea, #764ba2);
            border-radius: 2px;
        }
        
        .comparison-table {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
            border-left: 4px solid #667eea;
            padding: 1.5rem;
            margin: 1.5rem 0;
            border-radius: 0 8px 8px 0;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fade-in {
            animation: fadeInUp 0.8s ease-out;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center animate-fade-in">
            <h1 class="text-5xl md:text-6xl font-bold mb-6">
                Redis <span class="text-yellow-300">vs</span> Memcached
            </h1>
            <p class="text-xl md:text-2xl mb-8 opacity-90">深度对比两大内存缓存系统的设计哲学与应用场景</p>
            <div class="flex justify-center space-x-8 text-lg">
                <div class="flex items-center">
                    <i class="fas fa-database mr-2"></i>
                    <span>数据结构</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-tachometer-alt mr-2"></i>
                    <span>性能对比</span>
                </div>
                <div class="flex items-center">
                    <i class="fas fa-shield-alt mr-2"></i>
                    <span>持久化</span>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction -->
    <section class="py-16 px-6">
        <div class="max-w-4xl mx-auto bg-white rounded-2xl shadow-xl p-10">
            <p class="text-lg leading-relaxed text-gray-700">
                <span class="drop-cap">R</span>edis 和 Memcached 是两种流行的内存缓存系统，它们都广泛用于提高应用程序的性能，但它们在设计、功能和用途上存在一些关键差异。选择合适的缓存系统对于构建高性能应用至关重要。
            </p>
        </div>
    </section>

    <!-- Basic Concepts -->
    <section class="py-12 px-6">
        <div class="max-w-6xl mx-auto">
            <h2 class="section-title text-3xl font-bold mb-12 text-gray-800">基本概念</h2>
            <div class="grid md:grid-cols-2 gap-8 mt-8">
                <div class="card-hover bg-white rounded-xl p-8 shadow-lg">
                    <div class="flex items-center mb-4">
                        <div class="feature-icon w-16 h-16 bg-red-500 rounded-full flex items-center justify-center text-white text-2xl mr-4">
                            <i class="fas fa-cube"></i>
                        </div>
                        <h3 class="text-2xl font-bold text-gray-800">Redis</h3>
                    </div>
                    <p class="text-gray-600 leading-relaxed">
                        Redis 是一个开源的内存数据结构存储系统，可以用作数据库、缓存和消息代理。支持丰富的数据结构，包括字符串、哈希、列表、集合、有序集合、位图、HyperLogLog 和地理空间索引。
                    </p>
                </div>
                
                <div class="card-hover bg-white rounded-xl p-8 shadow-lg">
                    <div class="flex items-center mb-4">
                        <div class="feature-icon w-16 h-16 bg-blue-500 rounded-full flex items-center justify-center text-white text-2xl mr-4">
                            <i class="fas fa-memory"></i>
                        </div>
                        <h3 class="text-2xl font-bold text-gray-800">Memcached</h3>
                    </div>
                    <p class="text-gray-600 leading-relaxed">
                        Memcached 是一个高性能的分布式内存对象缓存系统，主要用于加速动态 Web 应用程序通过缓存数据库查询结果、API 调用和页面生成等。主要以键值对的形式存储数据，支持简单的字符串值和二进制数据。
                    </p>
                </div>
            </div>
        </div>
    </section>

    <!-- Architecture Comparison Diagram -->
    <section class="py-12 px-6 bg-gray-50">
        <div class="max-w-6xl mx-auto">
            <h2 class="section-title text-3xl font-bold mb-12 text-gray-800 text-center">架构对比图</h2>
            <div class="bg-white rounded-xl shadow-lg p-8">
                <div class="mermaid">
                    graph TB
                        subgraph Redis架构
                            R1[客户端] --> R2[Redis服务器]
                            R2 --> R3[内存存储]
                            R2 --> R4[持久化层]
                            R4 --> R5[RDB快照]
                            R4 --> R6[AOF日志]
                            R2 --> R7[数据结构]
                            R7 --> R8[字符串/哈希/列表/集合/有序集合等]
                        end
                        
                        subgraph Memcached架构
                            M1[客户端] --> M2[Memcached服务器]
                            M2 --> M3[内存存储]
                            M2 --> M4[简单键值对]
                            M3 -.->|无持久化| M5[内存数据]
                        end
                        
                        style R1 fill:#ff6b6b,stroke:#333,stroke-width:2px
                        style M1 fill:#4ecdc4,stroke:#333,stroke-width:2px
                        style R4 fill:#ffd93d,stroke:#333,stroke-width:2px
                </div>
            </div>
        </div>
    </section>

    <!-- Feature Comparison -->
    <section class="py-16 px-6">
        <div class="max-w-6xl mx-auto">
            <h2 class="section-title text-3xl font-bold mb-12 text-gray-800 text-center">核心特性对比</h2>
            
            <!-- Data Structure -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6 text-gray-700">
                    <i class="fas fa-layer-group mr-3 text-purple-500"></i>数据存储和结构
                </h3>
                <div class="comparison-table rounded-xl shadow-lg overflow-hidden">
                    <div class="grid md:grid-cols-2">
                        <div class="p-8 border-r border-gray-200">
                            <h4 class="font-bold text-red-500 mb-4 text-xl">Redis</h4>
                            <ul class="space-y-3 text-gray-600">
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                                    <span>支持多种数据结构：字符串、哈希、列表、集合、有序集合、位图、HyperLogLog 和地理空间数据</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                                    <span>提供丰富的操作命令，可以对数据进行复杂的查询和操作，如排序、聚合和计算</span>
                                </li>
                            </ul>
                        </div>
                        <div class="p-8">
                            <h4 class="font-bold text-blue-500 mb-4 text-xl">Memcached</h4>
                            <ul class="space-y-3 text-gray-600">
                                <li class="flex items-start">
                                    <i class="fas fa-minus-circle text-yellow-500 mt-1 mr-3"></i>
                                    <span>主要以键值对的形式存储数据，数据结构非常简单</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-minus-circle text-yellow-500 mt-1 mr-3"></i>
                                    <span>只支持字符串值和二进制数据，无法对数据进行复杂的操作</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Persistence -->
            <div class="mb-12">
                <h3 class="text-2xl font-semibold mb-6 text-gray-700">
                    <i class="fas fa-save mr-3 text-purple-500"></i>持久化
                </h3>
                <div class="comparison-table rounded-xl shadow-lg overflow-hidden">
                    <div class="grid md:grid-cols-2">
                        <div class="p-8 border-r border-gray-200">
                            <h4 class="font-bold text-red-500 mb-4 text-xl">Redis</h4>
                            <ul class="space-y-3 text-gray-600">
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                                    <span>支持持久化，将内存中的数据保存到磁盘，以防数据丢失</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-check-circle text-green-500 mt-1 mr-3"></i>
                                    <span>提供两种持久化方式：RDB（快照）和 AOF（追加文件）</span>
                                </li>
                            </ul>
                        </div>
                        <div class="p-8">
                            <h4 class="font-bold text-blue-500 mb-4 text-xl">Memcached</h4>
                            <ul class="space-y-3 text-gray-600">
                                <li class="flex items-start">
                                    <i class="fas fa-times-circle text-red-500 mt-1 mr-3"></i>
                                    <span>不支持持久化</span>
                                </li>
                                <li class="flex items-start">
                                    <i class="fas fa-times-circle text-red-500 mt-1 mr-3"></i>
                                    <span>所有存储的数据仅保存在内存中，服务器重启后数据会丢失</span>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Performance -->
            <div class="highlight-box">
                <h3 class="text-2xl font-semibold mb-4 text-gray-700">
                    <i class="fas fa-rocket mr-3 text-purple-500"></i>性能对比
                </h3>
                <div class="grid md:grid-cols-2 gap-6">
                    <div>
                        <h4 class="font-bold text-red-